//
//  Utils.h
//  NvSellerShow
//
//  Created by Meicam on 2017/2/25.
//  Copyright © 2017年 Meicam. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Macro.h"
#import "Colors.h"
#import "Config.h"
#import "NvsStreamingContext.h"
#import "Utils.h"
#import "UIImageView+WebCache.h"
#import "AssetPackageObject.h"

static inline CGSize CGSizeScale(CGSize size, CGFloat scale) {
    return CGSizeMake(size.width * scale, size.height * scale);
}

//palyer aspect ratio
typedef NS_ENUM(NSInteger, NvPlayerAspectRatioType){
    NvPlayerAspectRatio1x1 = 0,
    NvPlayerAspectRatio16x9
};

//create Mode
//typedef enum {
//    NvSSEditCreateModeMainImage = 0,
//    NvSSEditCreateModeDetailVideo,
//    NvSSEditCreateModeDetailVideo9X16
//} NvSSEditCreateMode;

//EditVideo Mode
typedef enum {
    AddCaption = 0,
    EditVideo,
    AddWaterMark
} EditVideoMode;

//compile for loacal or upload type
typedef NS_ENUM(NSInteger, NvCompileSaveMode) {
    NvCompileSaveModeLocal = 0,
    NvCompileSaveModeUpload = 1,
};

//uploadvideo type
typedef NS_ENUM(NSInteger, NvUpLoadVideoType) {
    //mainimage
    NvUpLoadVideoMainImage = 0,
    //videodetail
    NvUpLoadVideoDetailVideo
};

//login mode
typedef NS_ENUM(NSInteger, NvLoginMode) {
    NvLoginUseSecret= 0,
    NvLoginUseToken
};

NS_ASSUME_NONNULL_BEGIN

@interface Utils : NSObject
+ (instancetype)sharedUtils;

+ (BOOL)checkFileExist:(NSString *)filePath;

+ (NSString *)stringWithTime:(NSTimeInterval)time;

+ (NvsTimeline *)createTimeLine:(NvSSVideoCreateScale)editMode;
@end

NS_ASSUME_NONNULL_END

#import "Utils+CGHelper.h"
#import "Utils+IPhone.h"
#import "Utils+File.h"
#import "Utils+Application.h"
#import "Utils+Popover.h"
#import "Utils+Text.h"
#import "UIKit+Ext.h"
#import "Masonry.h"

#define NS_SCALE_IMAGE_PATH  @"scaledimages"
#define NS_COMPILE_VIDEO_PATH  @"video"
#define NS_TEMP_PATH  @"tmp"

#define NS_COMPILED_VIDEO_ASSETS_GROUP_NAME @"天马"

#pragma mark - Drafts relative

#define DraftArrayKey @"tianmaDrafts"
#define DraftCreatedDateKey @"draftDate"
#define DraftNameKey @"draftName"
#define DraftThumbDataKey @"draftThumb"

//project relative
#define DraftThemeNameKey @"draftThemeName"
#define DraftEditModeKey @"draftEditMode"
#define DraftThemeIdKey @"draftThemeId"
#define DraftSelectedMusicNameKey @"draftSelectedMusicName"
#define DraftSelectedMusicPathKey @"draftSelectedMusicPath"
#define DraftSelectedMusicTrimInKey @"draftSelectedMusicTrimIn"
#define DraftSelectedMusicTrimOutKey @"draftSelectedMusicTrimOut"
#define DraftOriginVolumeKey @"draftOriginVolume"
#define DraftMusicVolumeKey @"draftMusicVolume"
#define DraftStickerIdKey @"draftStickerId"

//cellModel relative
#define DraftModelsArrayKey @"draftModels"
#define DraftModelTypeKey @"draftModelType"
#define DraftModelTitleKey @"draftModelTitle"
#define DraftClipTypeKey @"draftClipType"
#define DraftClipPathKey @"draftClipPath"
#define DraftClipThumbDataKey @"draftClipThumbData"
#define DraftVideoClipTrimInKey @"draftVideoClipTrimIn"
#define DraftVideoClipTrimOutKey @"draftVideoClipTrimOut"
#define DraftImageClipDurationKey @"draftImageClipDuration"
#define DraftClipCaptionKey @"draftClipCaption"
#define DraftClipCaptionStyleIdKey @"draftClipCaptionStyleId"
#define DraftClipVolumenKey @"draftClipVolume"
#define DraftClipPanKey @"draftClipPan"
#define DraftClipScanKey @"draftClipScan"
#define DraftStickerPackageID   @"stickerPackageId"
#define DraftCaptionOffset    @"captionOffset"
#define DraftStickerOffset    @"stickerOffset"
#define DraftCaptionScale     @"captionScale"
#define DraftStickerScale     @"stickerScale"
#define DraftVideoFx          @"videoFx"
#define DraftTransitionImageNameKey @"draftTransitionImageName"
#define DraftTransitionTransitionNameKey @"draftTransitionTransitionName"
#define DraftTransitionTransitionSeeNameKey @"draftTransitionSeeName"
#define DraftTransitionCellImageNameKey @"draftTransitionCellImageName"

#define DraftVideoSpeed       @"videoSpeed"

#pragma mark - Notification
//save Draft
#define NotificationSaveDraft @"saveDraft"


#pragma mark - Setting Relative
#define Settings4GUploadTipKey @"4gUploadTip"

//#pragma mark - Macros SildeIn & SliedeOut Animation

//slide in animation
#define animationSlideIn() \
CATransition *animation = [CATransition animation]; \
animation.timingFunction = UIViewAnimationCurveEaseInOut; \
animation.type = @"push"; \
animation.duration = 0.2f; \
animation.subtype = kCATransitionFromRight; \
[[UIApplication sharedApplication].keyWindow.layer addAnimation:animation forKey:nil];

//slide out animation
#define animationSlideOut() \
CATransition *animation = [CATransition animation]; \
animation.timingFunction = UIViewAnimationCurveEaseInOut; \
animation.type = @"push"; \
animation.duration = 0.2f; \
animation.subtype = kCATransitionFromLeft; \
[[UIApplication sharedApplication].keyWindow.layer addAnimation:animation forKey:nil];


#define NS_TIME_BASE    1000000
#define NV_MAX_TEXTLENGTH  50

#define NSLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);

